<template>
  <el-menu 
    class="admin-navbar"
    :default-active="$route.path"
    mode="vertical"
    router
    @mouseenter="showFilter = true" 
    @mouseleave="showFilter = false"
  >
    <el-menu-item index="/admin/meeting-rooms">
      <el-icon><OfficeBuilding /></el-icon>
      <span>会议室管理</span>
    </el-menu-item>
    
    <el-menu-item index="/admin/users">
      <el-icon><User /></el-icon>
      <span>员工管理</span>
    </el-menu-item>
    <el-menu-item index="/" class="logout-item" @click="logout">
      <el-icon><CaretLeft /></el-icon>
    </el-menu-item>
  </el-menu>
</template>
  
<style scoped>
.el-menu {
  border-bottom: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 240px;
  height: 100vh;
  z-index: 1000;
  background: linear-gradient(180deg, #1a237e 0%, #283593 100%);
  color: white;
  box-shadow: 4px 0 10px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.el-menu-item {
  color: rgba(255, 255, 255, 0.85);
  height: 56px;
  line-height: 56px;
  margin: 8px 16px;
  border-radius: 8px;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 12px;
}

.el-menu-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
  transform: translateX(5px);
}

.el-menu-item.is-active {
  background: linear-gradient(90deg, #3949ab 0%, #5c6bc0 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.logout-item {
  position: absolute;
  bottom: 20px;
  left: 0;
  width: 100%;
  padding: 0 16px;
}

.logout-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: #ff5252;
}

.el-icon {
  font-size: 20px;
  margin-right: 8px;
}
</style>

<script setup>
import { ref } from 'vue'
import { OfficeBuilding, User } from '@element-plus/icons-vue'
import { useUserStore } from '../stores/UserStore'

const userStore = useUserStore()
const showFilter = ref(false)
defineExpose({ showFilter })

const logout = () => {
  userStore.clearUser()
  router.push('/login')
}
</script>